package zyc.dao.impl;

import zyc.dao.UserDao;
import zyc.pojo.User;

/**
 * @description:
 * @author: ZhaoYicong
 * @date: Created in 2020/7/15 22:09
 * @version: v1.0
 * @modified By:
 */
public class UserDaoimpl extends BaseDao implements UserDao {
    @Override
    public User qureUserByUsername(String name) {
        String sql="select id,username,password,email from t_user where username=?";
        return queryforone(User.class,sql,name);
    }

    @Override
    public User queryUserByUsernameAndPassword(String username, String password) {
        String sql="select id,username,password,email from t_user where username=? and password=?";
        return queryforone(User.class,sql,username,password);
    }

    @Override
    public int saveUser(User user) {
        String sql="insert into t_user(id,username,password,email) values(?,?,?,?)";
        return update(sql,user.getId(),user.getUsername(),user.getPassword(),user.getEmail());
    }
}
